import java.awt.Color;
public class Cartest{

	public static void main(String arg[]){
	int total =0;
	 Automobile[] fl = new Automobile[3];
		fl[0] = new Sedan(Color.black,5);
		fl[1] = new Minivan(Color.blue,8);
		fl[2] = new SportCar(Color.red,2);
	for(int i=0;i<fl.length;i++)
	{
	 total+= fl[i].getCapacity();
	}
	System.out.println("polymorphism사용 합계 : "+total);
	total =0;

	for(int i=0;i<fl.length;i++){
		if(fl[i] instanceof Sedan)
		total+=((Sedan)fl[i]).getCapacity();
		else if(fl[i] instanceof Minivan)
        	total+=((Minivan)fl[i]).getCapacity();
		else if(fl[i] instanceof SportCar)
        	total+=((SportCar)fl[i]).getCapacity();
		else 
		total += fl[i].getCapacity();
	}
	System.out.println("insteadof 사용 합계  : "+total);
	}
}
